"""
解题思路

这道题目思路不算复杂，即通过双指针来索引，需要注意特殊值的判定

"""


class Solution:
    def summaryRanges(self, nums: List[int]) -> List[str]:
        section = []
        start, end = 0, 1
        while end < len(nums):
            if nums[end] - nums[end-1] != 1:
                section.append(self.append(nums[start], nums[end-1]))
                start = end
            end += 1
        if len(nums):
            section.append(self.append(nums[start], nums[min(end-1, len(nums)-1)]))
        return section

    def append(self, start, end):
        if start == end:
            return str(start)
        else:
            return "%d->%d" % (start, end)